<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page isELIgnored="false" %>
<%@page import="dao.CommentDao"%>
<%@page import="dao.DaoFactory"%>
<%@page import="entity.Comment"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv=Content-Type content="text/html; charset=utf-8" />
		<link href="css/style1.css" type=text/css rel=stylesheet />
	</head>
	<body topMargin="10">
		<div id="append_parent"></div>
		<table cellSpacing=6 cellPadding=2 width="100%" border="0">
			<tbody>
				<tr>
					<td>
						<table class="guide" cellSpacing="0" cellPadding="0" width="100%"
							border="0">
							<tbody>
								<tr>
									<td>
										<a href='#'>主页</a>&nbsp;/&nbsp;
										<a href='#'>留言板MVC(WEB008)</a>&nbsp;/&nbsp;留言信息
									</td>
								</tr>
							</tbody>
						</table>
						<br />
<%
	CommentDao dao = DaoFactory.getInstance(CommentDao.class);
	List<Comment> comments=dao.findAll();
	session.setAttribute("comments",comments);
 %>
						<table class="tableborder" width="100%"
							style="border-collapse: collapse" cellpadding="8">
							<c:if test="${!empty comments}">
								<c:forEach var="comment" items="${comments}">
									<tr>
									<td width="15%" class="altbg1">
										<b>${comment.username}</b>
										<br />
										(${comment.date})
									</td>
									<td class="altbg2">
										<b>${comment.title}</b>
										<br />
										${comment.content}
									</td>
									</tr>
								</c:forEach>
							</c:if>

							

						</table>
						<br />
						<br />
						<br />
						<c:if test="${!empty id}">
							<form action="comment.do" method="post">
								<table class="tableborder" width="100%"
									style="border-collapse: collapse" cellpadding="8">
									<tr class="header">
										<td colspan="2">
											<b>发表评论</b>
										</td>
									</tr>
									<tr>
										<td class="altbg1">
											<b>信息标题：</b>
										</td>
										<td class="altbg2">
											*&nbsp;填写信息标题（最多不超过20字符）
											<span style="color: red"> </span>
											<br />
											<input type="text" size="78" name="title" />
										</td>
									</tr>
									<tr>
										<td class="altbg1">
											<b>信息内容：</b>
										</td>
										<td class="altbg2">
											*&nbsp;填写要发送信息（最多不超过500字符）
											<span style="color: red"> </span>
											<br />
											<textarea rows="10" cols="80" name="content"></textarea>
											<br />
											<input type="submit" value="发送" />
										</td>
									</tr>
								</table>
								<center>
									<input class="button" type="reset" value="退出"
										name="settingsubmit" onclick="location='logout.do'" />
								</center>
							</form>
						</c:if>
					</td>
				</tr>
			</tbody>
		</table>

	</body>
</html>